﻿using System;
using Alfa.Math;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Alfa.UnitsAndMath.Test.Math {
	[TestClass]
	public class UnitTestVector {
		public UnitTestVector( ) { }

		Vector a;
		Vector b;

		#region Additional test attributes
		//
		// You can use the following additional attributes as you write your tests:
		//
		// Use ClassInitialize to run code before running the first test in the class
		// [ClassInitialize()]
		// public static void MyClassInitialize(TestContext testContext) { }
		//
		// Use ClassCleanup to run code after all tests in a class have run
		// [ClassCleanup()]
		// public static void MyClassCleanup() { }
		//
		/// <summary>
		/// Use TestInitialize to run code before running each test
		/// </summary>
		[TestInitialize( )]
		public void MyTestInitialize( ) {
			this.a = new Vector(3, 5);
			this.b = new Vector(1, 2);
		}

		/// <summary>
		/// Use TestCleanup to run code after each test has run
		/// </summary>
		[TestCleanup( )]
		public void MyTestCleanup( ) {
			this.a = null;
			this.b = null;
		}
		#endregion

		[TestMethod]
		public void Vector_Negation( ) {
			Vector x = -this.a;

			Assert.AreEqual(new Vector(-3, -5), x);
		}

		[TestMethod]
		public void Vectors_Add( ) {
			Vector x = this.a + this.b;

			Assert.AreEqual(new Vector(4, 7), x);
		}

		[TestMethod]
		public void Vectors_Subtract( ) {
			Vector x = this.a - this.b;

			Assert.AreEqual(new Vector(2, 3), x);
		}

		[TestMethod]
		public void Vector_Multiply_Scalar( ) {
			Vector x = this.a * 3;

			Assert.AreEqual(new Vector(9, 15), x);
		}

		[TestMethod]
		public void Vector_Divide_Scalar( ) {
			Vector x = this.a / 3;

			Assert.AreEqual(new Vector(1, 5.0f / 3.0f), x);
		}
	}
}
